package cn.edu.nuc.onlinestore.control;

import java.util.List;

import cn.edu.nuc.onlinestore.io.SerilizableText;

//import java.util.ArrayList;
//import java.util.List;

import cn.edu.nuc.onlinestore.model.Goods;

public class OprGoods {
    private static int pid=1;  //商品编号初始化。
    private static String p = new String("/goods");  

	//添加商品
	public static void addGood(String goodName, float price,int num ,String brifeintro){
		Goods g1 = new Goods();
		g1.setGid(pid++);
		g1.setGoodsName(goodName);
		g1.setPrice(price);
		g1.setNum(num);
		g1.setBrifeintro(brifeintro);
		//以商品的ID为文件名字序列到文件中。                                   
		String filename = "/"+ g1.getGid() +".dat";
		SerilizableText.Serializable(p ,filename, g1);	
	}

	//删除商品
	public static void deleteGood(int id){
	  

	}
	
	//修改商品
	
	//查询商品
	
	//输出全部商品
	public static Goods getAll(){
		
		List<Goods> list = SerilizableText.deSeralizableAll(p);
		for(Goods good : list){
			return good;
		}
		return null;
	}
}
